package edu.uw.tcss360.group6.model;

import java.util.*;


@SuppressWarnings("serial")
public class Category implements java.io.Serializable {

    private String my_name;
	private Map<String,Entry> my_entries;
    private List<Judge> my_judges;
	
	public Category(String name) {
        my_name = name;
		my_entries = new HashMap<String,Entry>();
        my_judges = new ArrayList<Judge>();
	}
	
	//TODO: this is not very good OO design. Fix. -David
	public Map<String, Entry> getEntries() {
		return my_entries;
	}

    public String getName() {
        return my_name;
    }

    public void addEntry(Entry entry) {
        //TODO: Exception states
        my_entries.put(entry.getID(),entry);
    }

    public Judge[] getJudges() {
        return my_judges.toArray(new Judge[my_judges.size()]);
    }


    public Contestant[] getContestants() {
        HashSet<Contestant> contestants = new HashSet<Contestant>(my_entries.size());
        for(Entry e : my_entries.values()) {
            contestants.add(e.getContestant());
        }
        return contestants.toArray(new Contestant[contestants.size()]);
    }

    public String toString() {
        return getName();
    }
}
